package com.itheima.safe;

/**
 * @author Anomaly
 * @date 2023/2/10 15:46
 */
public class Account {
    private double money;

    public Account() {
    }

    public Account(double money) {
        this.money = money;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public void drawMoney(double money) {
        String name = Thread.currentThread().getName();
        synchronized (this) {
            if (this.money >= money) {
                System.out.println(name + "成功取出：" + money);
                this.money -= money;
            } else {
                System.out.println(name + "取钱失败");
            }
            System.out.println(name + "取完了，账户当前剩余：" + this.money);
        }
    }
}
